UE4 stats文件Profiler工具

您所在的位置:网站首页 ue4 android UE4 stats文件Profiler工具

UE4 stats文件Profiler工具

#UE4 stats文件Profiler工具| 来源: 网络整理| 查看: 265

Profiler工具的代码详见:UnrealEngine\Engine\Source\Developer\Profiler

UE4提供了2种使用Profiler工具的方式:

① UE4编辑器中的Session Frontend面板,见菜单“Window” -- “Developer Tools” -- “Session Frontend”

② 独立的UnrealFrontend工具

 

离线模式 控制台命令抓取性能数据并保存到文件

stat startfile // starts a stats capture, creating a new file in the Profiling directory; stop with stat StopFile to close the file

stat stopfile  // stops dumping a capture (regular, raw, memory).  finishes a stats capture started by stat StartFile

stat startfileraw  // starts dumping a raw capture.  4.26版本可以生成ue4statsraw文件,但是Profiler工具不能支持该文件的读取   注:详见FProfilerManager::LoadRawStatsFile函数

stat stopfileraw   // 功能与stat stopfile一致

 

UE4Editor.exe "%GameDir%\MyGame.uproject" TestMap_Main -game -ExecCmds="stat startfile"   // 启动游戏后,然后执行stat startfile命令

 

ue4stat文件保存在:Saved\Profiling\UnrealStats目录中

 

在代码中开启和关闭stat文件

#if STATS DirectStatsCommand(TEXT("stat startfile")); #endif #if STATS DirectStatsCommand(TEXT("stat stopfile"),true); #endif

 

Profiler工具读取性能数据

在Frontend工具中的Profiler标签下,点击Load来读取ue4stat文件

也可以点击Load Folder来加载某个目录下的所有ue4stat文件

注:红框处会列出所有的ue4stat文件, 点击即可切换

 

实时模式

 

首先需要在uproject文件中启用TcpMessaging、UdpMessaging插件   注:默认会启用,但uproject中可将其关闭

 

本机或USB数据线的连接模式 游戏侧

UE4Editor.exe %GameDir%\MyGame.uproject -skipcompile  // 编辑器

UE4Editor.exe %GameDir%\MyGame.uproject ThirdPersonExampleMap -messaging -SessionName=mySession -game -skipcompile  // standalone单机  对本机或USB数据线连接的机器上的UnrealFrontend可见

Profiler工具侧

UE4Editor.exe %GameDir%\MyGame.uproject -skipcompile

UnrealFrontend.exe

 

同一wifi网络的连接模式 游戏侧

PC:UE4Editor.exe %GameDir%\MyGame.uproject ThirdPersonExampleMap -messaging -SessionName=mySession -TcpMessagingConnect=10.46.80.61:7777 -game -skipcompile  // 以standalone启动ThirdPersonExampleMap地图,并连接到10.46.80.61:7777

Android:UE4CommandLine.txt写入如下内容,并adb push到手机的UE4Game/UAGame目录中

-messaging TcpMessagingConnect=10.46.80.61:7777 -SessionOwner=kekec -SessionName=fps1

IOS:ue4commandline.txt(注:要全小写)写入与Android一样的内容,并放到如下目录中

日志窗口默认会Follow Scroll来显示最新的日志输出,若想看上面的日志,可按Home键将光标移到顶部,然后再滚动到自己想看的地方

若想继续Follow Scroll,按End键将光标移到底部即可

 

Profiler工具侧

UE4Editor.exe %GameDir%\MyGame.uproject -TcpMessagingListen=10.46.80.61:7777 -SessionOwner=kekec -skipcompile  //  启动编辑器并监听10.46.80.61:7777   注:10.46.80.61为编辑器所在机器的IP    kekec为当前计算机的登录用户名

UnrealFrontend.exe -TcpMessagingListen=10.46.80.61:7777 -SessionOwner=kekec  //  启动UnrealFrontend.exe并监听10.46.80.61:7777   注:10.46.80.61为UnrealFrontend所在机器的IP   kekec为当前计算机的登录用户名

 

实时Profiler

为tips触发区域,鼠标放置上去,会显示更详细的信息说明

 

Load:加载一个ue4stats文件

Load Folder:加载一个目录下的所有ue4stats文件

Data Preview:在左侧选中一个Session后, 点击该按钮可实时profiler

Live preview:让下面的GR红蓝条、Graph View条Scroll到最新帧

Data Capture:startfile / stopfile

Statistics:开启Stats Profiler

FPS Chart:统计整个文件的fps分布

 

面板其他功能说明 

GR红蓝条说明

① 红色为Game Thread的耗时(含Waiting那部分时间)  -- 即FrameTime

② 蓝色为Rendering Thread的耗时(含Waiting那部分时间)

③ 通过红蓝条的高度,可快速找到耗时的区域部分

 

Graph View说明

① 双击左边Panel中的统计细项,会在Graph View上绘制出其各帧的数值曲线

② (Threads) GameThread [0x1d3b] 24.06(MS)/Calls 1 - {Value Min:22.796 Avg:45.743 Max:1857.557(MS) / Calls (100%) Min:1.0 Avg:1.0 Max:1.0}

③ 数值曲线下面的时间信息(907.7s、921.6s、934.7s 。。。)是错误的

 

Stat统计项

所有统计大类如下:

Group Name为Memory的统计细项如下:

统计项类型:

为hierarchy类别,可以嵌套子节点,包含CallCount、InclusiveTime、ExclusiveTime等字段

为int或float数字类型

为Memory类型

 

hierarchy类别数据CallStack

 

工具栏说明:

① Type有:OneFrame(选中一帧时)     Average、Maximum(拉框选中一个区域时)

② View mode:Hierarchical(层次树,按Inc Time排序)、

                          Inclusive(Flat方式,按Inc Time排序)、Inclusive(Flat方式,同名统计项合并在一起,按Inc Time排序)

                          Exclusive(Flat方式,按Exc Time排序)、Exclusive(Flat方式,同名统计项合并在一起,按Exc Time排序)

③   帧选择的Undo、Redo

④   快速展开选中节点Inc Time消耗最高的路径

 

其他区域说明: 

① 在Event Name层次树中的统计项均为hierarchy类别。背景色越红,说明该项的Inc Time(MS)就越高,耗时也就越高

② IncTime的两列为包含时间,Exc Time的两列为独占时间,数据为0,是显示问题;Calls为当前帧该项统计次数

③ Event Name层次树的顶层节点均为Thread。如:StatsThread [0x1d83]    其中StatsThread为线程名,0x1d83为16进制的线程ID

④ 可先通过Thread下拉框选择自己感兴趣的线程,那么其他线程就会变灰;重新选做None后,就全部恢复正常

⑤ 在Event Name层次树中,选中一个节点后,左边Calling Functions下会画出父节点的按钮,点击后,会往顶层回溯;中间Current Function为选中节点;

     右边Called Functions下会画出所有子节点的按钮,点击后,会往下回溯;名为Self的子节点比较特殊,它的Inc Time(MS)表示其父节点的独占时间。

 

右键快捷菜单和快捷键说明:

①  Expand All(展开所有子节点) --> Ctrl + A(全选)

② 按住Ctrl或Shift来快速多选

③ Select Stack:向顶层回溯,选中整个Stack

④ Copy To Clipboard(快捷键为Ctrl + C):可以将选中的节点拷贝到剪切板中

 

参考

分析工具参考

UE4 Android下实时profile获取数据

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3